package com.vortex.cloud.zhsw.xinyang.service.impl;

import com.google.common.collect.Maps;
import com.vortex.cloud.zhsw.xinyang.dto.DictDataDTO;
import com.vortex.cloud.zhsw.xinyang.service.EhcacheDemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author ChenY
 * @Date 2022/5/10 14:07
 **/
@Slf4j
@Component
public class EhcacheDemoServiceImpl implements EhcacheDemoService {

    private final static Map<String,String> DB1 = Maps.newConcurrentMap();
    private final static Map<String, List<DictDataDTO>> DB2 = Maps.newConcurrentMap();

    @Override
    public void update(String tenantId, String value) {
        log.info("EhcacheDemoService：更新数据，key={},value={}",tenantId,value);
        DB1.put(tenantId, value);
    }

    @Override
    public String get(String tenantId) {
        log.info("EhcacheDemoService：查询数据，key={}",tenantId);
        return DB1.get(tenantId);
    }

    @Override
    public void updateList(String tenantId, List<DictDataDTO> value) {
        log.info("EhcacheDemoService：更新数据，key={},value={}",tenantId,value);
        DB2.put(tenantId, value);
    }

    @Override
    public List<DictDataDTO> getList(String tenantId) {
        log.info("EhcacheDemoService：查询数据，key={}",tenantId);
        return DB2.get(tenantId);
    }
}
